package srx.open.com.views;

import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.ScrollView;

/**
 * RefreshListView Header Controller.
 */
public class RefreshHeaderController {

    private float mStartX;
    private float mStartY;
    private int mOffsetX;
    private int mOffsetY;

    private int mCurrentPos = -1;
    private int mMaxHegiht;
    private int mMinHegiht;

    public int getOffsetX() {
        return mOffsetX;
    }

    public int getOffsetY() {
        return mOffsetY;
    }

    public void onTouchDown(float x, float y) {
        mStartX = x;
        mStartY = y;
        mOffsetX = mOffsetY = 0;
    }

    public void onTouchMove(float x, float y) {
        mOffsetX = (int) (x - mStartX);
        mOffsetY = (int) (y - mStartY);
    }

    public boolean canMoveUpHead(RefreshListView absListView) {
        int headCount = absListView.getHeaderViewsCount() - 1;
        return absListView.getChildCount() > 0 && absListView.getFirstVisiblePosition() > headCount;
    }

    public boolean canScrollDownHead(RefreshListView absListView) {
        int headCount = absListView.getHeaderViewsCount();
        return absListView.getChildCount() > 0 && absListView.getFirstVisiblePosition() < headCount;
    }
}
